package com.example.tupu.repository;


import com.example.tupu.entity.Event;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface EventRepository extends Neo4jRepository<Event,Long> {
    List<Event> findAllByTitle(String title);

    List<Event> findAllByTitleLike(String title);
    @Query("MATCH (n:Event) WHERE n.title =~ ('.*'+$title+'.*') RETURN n")
    Event findEventTitle(String title);

    @Query("match (n)-[d:INCIDENT_IN]->(m) where d.Adyear > $startyear and d.Adyear < $endyear and d.Adyear <> 0 return m")
    List<Event> findEvenByAdyear(Long startyear,Long endyear);

}
